package com.selfdriving.activity;

import java.util.ArrayList;
import java.util.List;
import net.tsz.afinal.annotation.view.ViewInject;
import com.selfdriving.R;
import com.selfdriving.adapter.NearbyFriendAdapter;
import com.selfdriving.bean.User;
import com.selfdriving.dialog.ChooseDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;

public class NearbyFriendActivity extends BaseActivity  {
	@ViewInject(id = R.id.friend_list)
	ListView friend_list;

	private NearbyFriendAdapter adapter;

	private List<User> users;

	private ChooseDialog chooseDialog;
	
	private View view;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.nearby_friend);
		users = new ArrayList<User>();
		chooseDialog = new ChooseDialog(getParent());
		view = getLayoutInflater().inflate(R.layout.list_head, null);
		for (int i = 0; i < 7; i++) {
			User user = new User();
			users.add(user);
		}
		adapter = new NearbyFriendAdapter(this, users);
		friend_list.addHeaderView(view);
		friend_list.setAdapter(adapter);
		TextView button = (TextView) view.findViewById(R.id.tvChoose);
		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				chooseDialog.show();
			}
		});
		
		friend_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				if(arg2==0){
					return;
				}
				Intent intent = new Intent(NearbyFriendActivity.this,TravelDetailsActivity.class);
				startActivity(intent);
			}
		});
	}


}
